//
//  SYYParentVC.m
//  NineteenBook
//
//  Created by xhkj on 2021/8/4.
//  Copyright © 2021 UP. All rights reserved.
//

#import "SYYParentVC.h"

@interface SYYParentVC ()

//@property(nonatomic,strong)UIImageView *bgImageView;


@property (nonatomic, weak) UITableView *tableView;
@property (nonatomic, strong) UICollectionView *collectionView;

@property (nonatomic, strong) UIView *noDataView;



@end

@implementation SYYParentVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = HHColorBgColor;
    
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    if (self.navigationController.childViewControllers.count>1) {
        self.tabBarController.tabBar.frame = CGRectZero;
        self.tabBarController.tabBar.hidden = YES;
    }else{
        self.tabBarController.tabBar.hidden = NO;
        self.tabBarController.tabBar.frame = CGRectMake(0, ScreenHeight - TabBarHeight, ScreenWidth, TabBarHeight);
    }
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}





-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleDefault;
}






#pragma mark - tableView加载刷新
- (void)refreshMethod {}
- (void)loadMore {}
- (void)endRefresh {
    if (self.tableView) {
        if ([self.tableView.mj_header isRefreshing]) {
            [self.tableView.mj_header endRefreshing];
        }
        if ([self.tableView.mj_footer isRefreshing]) {
            [self.tableView.mj_footer endRefreshing];
        }
    }
    if (self.collectionView) {
        if ([self.collectionView.mj_header isRefreshing]) {
            [self.collectionView.mj_header endRefreshing];
        }
        if ([self.collectionView.mj_footer isRefreshing]) {
            [self.collectionView.mj_footer endRefreshing];
        }
    }
}
- (void)endMJRefreshingNoMoreData {
    if (self.tableView) {
        [self.tableView.mj_footer endRefreshingWithNoMoreData];
    }
    if (self.collectionView) {
        [self.collectionView.mj_footer endRefreshingWithNoMoreData];
    }
}
- (void)resetNoMoreData {
    if (self.tableView) {
        [self.tableView.mj_footer resetNoMoreData];
    }
    if (self.collectionView) {
        [self.collectionView.mj_footer resetNoMoreData];
    }
}







#pragma mark - 暂无数据
- (void)showNoDataView{
    if (self.tableView) {
        [self.tableView addSubview:self.noDataView];
    }
    if (self.collectionView) {
        [self.collectionView addSubview:self.noDataView];
    }
}
- (void)hiddenNoDataView{
    [self.noDataView removeFromSuperview];
}
- (void)showNoDataView:(NSString *)text imgStr:(NSString *)imgstr
{
    if (self.tableView) {
        [self.tableView addSubview:self.noDataView];
    }
    if (self.collectionView) {
        [self.collectionView addSubview:self.noDataView];
    }
    
    if (text) {
        self.noDataLab.text = text;
    }
    if (imgstr) {
        self.noDataImgV.image = HHIMAGE(imgstr);
    }
}
- (void)showNoDataView:(NSString *)text imgStr:(NSString *)imgstr frame:(CGRect)frame
{
    if (self.tableView) {
        [self.tableView addSubview:self.noDataView];
    }
    if (self.collectionView) {
        [self.collectionView addSubview:self.noDataView];
    }
    
    if (text) {
        self.noDataLab.text = text;
    }
    if (imgstr) {
        self.noDataImgV.image = HHIMAGE(imgstr);
    }
    
    CGFloat noDataWidth = frame.size.width;
    CGFloat noDataHeight = frame.size.height;
    [self.noDataImgV sizeToFit];
    CGFloat imageWidth = self.noDataImgV.width;
    CGFloat imageHeight = self.noDataImgV.height;
    self.noDataView.frame = frame;
    self.noDataImgV.frame = CGRectMake((noDataWidth-imageWidth)/2.0, (noDataHeight-imageHeight)/2.0, imageWidth, imageHeight);
    self.noDataLab.frame = CGRectMake(15, CGRectGetMaxY(self.noDataImgV.frame) + 10, noDataWidth-30, 20);
    
    self.noDataView.layer.cornerRadius = 5.0;
}

-(void)setNoDataImageViewTopSpace:(CGFloat)top width:(CGFloat)width height:(CGFloat)height{
    [self.noDataImgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.noDataView.mas_centerX);
            make.top.equalTo(@(top));
            make.width.equalTo(@(width));
            make.height.equalTo(@(height));
    }];
    
    self.noDataImgV.frame = CGRectMake((self.noDataView.width-width)/2, top, width, height);
    self.noDataLab.frame = CGRectMake(0, self.noDataImgV.bottom+10, self.noDataView.width, 20);
    
}

- (UIView *)noDataView{
    if (!_noDataView) {
        _noDataView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight - NavBarHeight)];

        _noDataView.backgroundColor = HHColorHexFFFFFF;
        _noDataView.userInteractionEnabled = NO;
        UIImageView *noDataImgV = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/2.0-100, ScreenHeight/2.0-150, 200, 200)];
        [_noDataView addSubview:noDataImgV];
        self.noDataImgV = noDataImgV;
        noDataImgV.contentMode = UIViewContentModeCenter;
        noDataImgV.image = HHLIBIMAGE(NullImage);
        _noDataView.userInteractionEnabled = YES;
        [_noDataView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(touchNoDataViewMethod)]];
        
        UILabel *noDataLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(noDataImgV.frame) + 30, ScreenWidth-30, 20)];
        [_noDataView addSubview:noDataLabel];
        self.noDataLab = noDataLabel;
        noDataLabel.font = [UIFont systemFontOfSize:14];
        noDataLabel.textColor = HHColorHex979797;
        noDataLabel.textAlignment = NSTextAlignmentCenter;
        noDataLabel.text = @"暂无内容";
    }
    return _noDataView;
}

- (void)touchNoDataViewMethod{
}



@end
